﻿Imports System
Imports System.IO
Imports System.Data.OleDb
Imports System.Data
Imports System.Drawing
Imports System.Drawing.Imaging

Namespace Arwani
    Partial Class Backend_AddDivision
        Inherits System.Web.UI.Page

        Public Function CheckPageExistance() As Boolean

            Dim strQ As String
            Dim arwCon As New ArwaniController
            Dim count As String

            strQ = "select count(*) as countTitle  from AddSEO where PageName='" & Me.txtPageName.Text & "'"
            Dim dtTable As DataTable = arwCon.ExecuteQuery(strQ)
            count = dtTable.Rows(0)("countTitle").ToString()
            If (count > 0) Then
                Return True
            Else
                Return False
            End If

        End Function

        Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
            Dim strQ As String
            Dim arwCon As New ArwaniController
            
            If (CheckPageExistance()) Then
                lblError.Text = "Page Name already Exists !"
            Else
                strQ = "insert into AddSEO (Title,PageName,	Description,keywords) values ('" & Me.txtTitle.Text & "','" & Me.txtPageName.Text.ToLower() & "','" & Me.txtDescription.Text & "','" & Me.txtKeywords.Text & "')"
                arwCon.ExecuteNonQuery(strQ)
                Response.Redirect("ManagePageSEO.aspx")
            End If

        End Sub

        Protected Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancel.Click
            Response.Redirect("ManagePageSEO.aspx")
        End Sub
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If (Session("ADMIN_USER") Is Nothing) Then
                Response.Redirect("Default.aspx")
            End If
        End Sub

    End Class
End Namespace